<?php

namespace App\FrontModule\Presenters;

use App\Model\Dao\Article;

/**
 * Article presenter.
 */
class ArticlePresenter extends BasePresenter {
 
  private $article;
  
  /**
   * Default action
   * @param String $link
   */
  public function actionDefault($link = NULL){
    if(!isset($link)){
      $this->redirect('Homepage:default');
    }
    
    $this->article = $this->em->getDao(Article::getClassName())->findOneBy(array('link' => $link));
    
    if(!$this->article){
      $this->redirect('Homepage:default');
    }
  }
  
  /**
   * Default render
   * @param String $link
   */
  public function renderDefault($link = NULL){
    $this->template->article = $this->article;
  }
}
